package jtwittconsolepackage;

import java.util.Calendar;
import java.text.SimpleDateFormat;

/**
 * The class DateUtils provides only one method which returns the current time
 * in a specified layout.
 */
public class DateUtils
{

    /**
     * Possible formats:
     * "dd MMMMM yyyy"
     * "yyyyMMdd"
     * "dd.MM.yy"
     * "MM/dd/yy"
     * "yyyy.MM.dd G 'at' hh:mm:ss z"
     * "EEE, MMM d, ''yy"
     * "h:mm a"
     * "H:mm:ss:SSS"
     * "K:mm a,z"
     * "yyyy.MMMMM.dd GGG hh:mm aaa"
     * @param dateFormat the needed date format
     * @return actual date in given format
     */
    public static String now(String dateFormat)
    {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        return (sdf.format(cal.getTime()));
    }
}
